package com.zj.common.util;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class ResponseUtil {
/*
 * 定义状态返回值
 */
	public final static String	TRUE_CODE="1000";
	//token过期
	public final static String	NOTOEKN_CODE="1001";
	//其他异常
	public final static String	TOKENFALSE_CODE="1002";
	//其他异常
	
	public final static String	OTHERFALSE_CODE="1003";
	
	//返回原始map，封装
	public static JSONObject getMap(Object code,Object msg,Object data){
		JSONObject j = new JSONObject();
		
		 if(StringMyUtil.isEmpty((String) msg)){
			 msg="操作成功";
		 }
		 j.put("code", code);
		 j.put("msg", msg);
		 j.put("data", data);
		 return j;
		 
		
	}
	
	//返回原始map
	public static String  getJson(Object code,Object msg,Object data){
			 Map<String,Object> map =  new HashMap<>();
			 map.put("code", code);
			 map.put("msg", msg);
			 map.put("data", data);
			String json =JSON.toJSONString(map);
			 return json;
			 
			
		}
	
}
